using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;

namespace DataAccess.BusinessEntities
{
    [DataContract(IsReference = true)]
    public class Product : IEntity
    {
        [DataMember]
        public virtual int Id { get; set; }
        [DataMember]
        public virtual int ContainerId { get; set; }
        [DataMember]
        public virtual int SubstanceId { get; set; }
        [DataMember]
        public virtual decimal? Price { get; set; }
        [DataMember]
        public virtual string CountryOfOrigin { get; set; }
        [DataMember]
        public virtual string Manufacturer { get; set; }
        [DataMember]
        public virtual Substance Substance { get; set; }
        [DataMember]
        public virtual Container Container { get; set; }
        [DataMember]
        public virtual ICollection<User> Users { get; set; }
        [DataMember]
        public string Name
        {
            get
            {
                string result;
                if (this.Container.NumberOfContainers > 1)
                {
                    result = String.Format("{0} {1}x{2:F2} ml", this.Substance.Name, this.Container.NumberOfContainers, this.Container.ContainerCapacity);
                }
                else
                {
                    result = String.Format("{0} {1:F0} ml", this.Substance.Name, this.Container.ContainerCapacity);
                }

                return result;
            }
            set { }
        }
        [DataMember]
        public bool UsedByUser { get; set; }
        [DataMember]
        public bool IsDeleted { get; set; }
    }
}